package view;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class MainFrame extends JSplitPane {
	private static final long serialVersionUID = -8024529317729286844L;
	private FrameWork frameWork = null;
	
	/**
	 * This is the default constructor
	 */
	public MainFrame(FrameWork frameWork) {
		super();
		
		this.frameWork = frameWork;
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setFullSize();
	}
	
	public void setCenteredRightComponent(JComponent component) {
		if(component instanceof PanelLocation) {
			((PanelLocation) component).centerOnFrame(this.getWidth() - getDividerLocation(), 0);
			this.setRightComponent(component);
		} else if(component instanceof JPanel) {
			component.setSize(this.getLeftComponent().getWidth(), this.getLeftComponent().getHeight());
			this.setRightComponent(component);
		} else
			this.setRightComponent(component);		
	}
	
	public void setDividerLocation() {
		this.setDividerLocation(0.2);
	}
	
	public void setFullSize(){
		this.setSize(frameWork.getJDesktopMainPane().getSize());
		this.setDividerLocation();
		this.updateUI();
	}
	
	public FrameWork getFrameWork() {
		return frameWork;
	}
	
	public FrameWork getContainer() {
		return this.frameWork;
	}
}
